package cn.net.xyan.easy.spring.jpa.test.entity;

import cn.net.xyan.easy.spring.jpa.annotation.Sequence;
import cn.net.xyan.easy.spring.jpa.test.entity.format.TestEntityFormat;
import cn.net.xyan.easy.spring.jpa.utils.sequence.TableSequenceGenerator;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * Created by zarra on 16/1/21.
 */
@Entity
@Table(name = "test_entity")
public class EntityA {

    //static private final String SeqGenerator = "cn.net.xyan.easy.spring.jpa.test.entity.EntityA.seq";

    String seq;
    String compare;

    Integer intValue;

    Long longValue;

    String value;

    EntityB entityB;

    @Id
    @Column(name = "id",updatable = false,nullable = false,length = 32)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = EntityA_.SEQ_)
    @GenericGenerator(name = EntityA_.SEQ_,
            strategy = TableSequenceGenerator.STRATEGY,
            parameters = {
                    //@org.hibernate.annotations.Parameter(name = "format", value = "LD0000000")
                    @org.hibernate.annotations.Parameter(name = "formatClass", value = TestEntityFormat.ClassName)
            })
    public String getSeq() {
        return seq;
    }

    public void setSeq(String seq) {
        this.seq = seq;
    }

    @Sequence(value = EntityA_.COMPARE_,format = TestEntityFormat.class)
    @Column(name = "compare",updatable = false,unique = true)
    public String getCompare() {
        return compare;
    }

    public void setCompare(String compare) {
        this.compare = compare;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Sequence(value = EntityA_.INTVALUE_)
    @Column(name = "intValue",updatable = false)
    public Integer getIntValue() {
        return intValue;
    }

    public void setIntValue(Integer intValue) {
        this.intValue = intValue;
    }

    @Sequence(value = EntityA_.LONGVALUE_)
    @Column(name = "longValue",updatable = false)
    public Long getLongValue() {
        return longValue;
    }

    public void setLongValue(Long longValue) {
        this.longValue = longValue;
    }

    @ManyToOne
    public EntityB getEntityB() {
        return entityB;
    }

    public void setEntityB(EntityB entityB) {
        this.entityB = entityB;
    }
}
